//
//  AppDelegate.swift
//  WB_Swift3.0
//
//  Created by wangrui on 2017/3/8.
//  Copyright © 2017年 wangrui. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
    {
        window = UIWindow()
        window?.backgroundColor = UIColor.white
        let vc = TabBarController()
        window?.rootViewController = vc
        window?.makeKeyAndVisible()
        loadAppInfo()
        return true
    }

    private func loadAppInfo()
    {
        DispatchQueue.global().async
        {
            let url = Bundle.main.url(forResource: "main.json", withExtension: nil)
            let data = NSData(contentsOf: url ?? URL(fileURLWithPath: ""))
            let documentFile = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
            let filePath = (documentFile as NSString).appendingPathComponent("main.json")
            data?.write(toFile: filePath, atomically: true)
        }
    }
}

